let db = require("../commons/db")
let JSONResponse = require("../commons/JSONResponse")

exports.getCategory = (req, resp) => {
    console.log("getCategory")
    db.query("select * from community_category")
        .then(res => {
            console.log("categroy_name", res)
            if (res) {
                resp.json(JSONResponse.success(res, 200, "获取成功"))
            }
            else resp.json(JSONResponse.fail("获取失败", 400, null))
        })
}

exports.getimages = (req, resp) => {
    let id = Number(req.params.id)
    // console.log("id", id)
    db.query("select * from community_category A inner join community B on A.id=B.category_id where A.id=?", [id])
        .then(res => {
            // console.log("newsDetail", res)
            if (res) {
                resp.json(JSONResponse.success(res, 200, "获取成功"))
            }
            else resp.json(JSONResponse.fail("获取失败", 400, null))
        })
}